﻿using System;
using System.Linq;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using System.Data.Services.Client;
using Slma.OData;

// Author: Miroslav Matula m.matula@alutam.cz 
// Date : 11.8.2010

namespace Silverlight.Test
{
  [TestClass]
  public class EntityTests
  {
    [TestMethod]
    public void T01_CreateEntityDynType()
    {
      Type entityType = Slma.OData.Factory.ClassFactory.GetAnonymousType(typeof(Silverlight.Test.CustomService.Product));
      // matouci typ - jesli se nepřepisují statické hodnoty
      Type entityType2 = Slma.OData.Factory.ClassFactory.GetAnonymousType(typeof(AA)); 
      //-- Create Entity ------------
      var productGen = Activator.CreateInstance(entityType) as Entity<Silverlight.Test.CustomService.Product>;
      Assert.IsNotNull(productGen);
      //-- SetData ----------------
      var product = new Silverlight.Test.CustomService.Product {
        Color = "Silver",
        ListPrice = 10.99M,
        Name = "Bike",
        ProductID = Guid.NewGuid(),
        ProductNumber = "CCC",
        SellStartDate = DateTime.Now.Date,
        Size = 44,
        StandardCost = 15M,
        Weight = 1.5M
      };
      productGen.SetData(product);
      var productGen2 = productGen.CreateODataEntity();
    }

  }

  public class AA
  {
    public int MyProperty1 { get; set; }
    public string MyProperty2 { get; set; }
  }
}
